<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button id="btn">点击获取数据</button>
  <script>
    const btn = document.getElementById("btn")
    btn.onclick = () => {
      const scriptNode = document.createElement("script")
      scriptNode.src = "http://localhost:8080/test?callback=peiqi"
      document.body.appendChild(scriptNode)
      window.peiqi = (a) => {
        console.log(a);
      }
      document.body.removeChild(scriptNode)
    }
  </script>
</body>
</html>